﻿using Estsh.Core.Model.EnumUtil;
using Estsh.Core.Models;
using Estsh.Core.Quartz.BaseService;
using Estsh.Core.Util;
using Estsh.Core.Wms.IRepositories;

namespace Estsh.Core.Wms.Jobs
{
    /// <summary>
    /// 成品下线打包座椅入库时将条码和通道号信息回传到WMS
    /// </summary>
    public class OutPdlineReceiveJob : IJobService
    {
        private readonly IOutPdlineReceiveRepository repository;

        public OutPdlineReceiveJob(IOutPdlineReceiveRepository _repository)
        {
            this.repository = _repository;
        }

        public string ExecuteService(string parameter)
        {
            try
            {
                List<MesWmsPgReceive> wmsRetrs = repository.GetOutPdlineReceiveInfo();
                if (wmsRetrs.Count <= 0)
                {
                    return "没有待处理的成品下线回传信息数据！";
                }
                repository.InsertOutPdlineReceiveInfo(wmsRetrs); //

                return "成品下线回传信息成功！";

            }
            catch (Exception ex)
            {
                LogHelper.Error("成品下线回传信息同步错误！" + ex);
                return "成品下线回传信息同步错误！" + ex.Message;
            }
        }
    }
}
